home *** CD-ROM | disk | FTP | other *** search
/ The Fatted Calf / The Fatted Calf.iso / Applications / Utilities / WhosOnFirst / Source / IconView.m < prev    next >
Encoding:
Text File  |  1994-05-23  |  3.1 KB  |  143 lines

  1.  
  2. /* IconView.m */
  3.  
  4. #import <appkit/graphics.h>
  5. #import <dpsclient/psops.h>
  6. #import <dpsclient/wraps.h>
  7. #import <strings.h>
  8. #import "IconView.h"
  9. #import "ProcessManager.h"
  10.  
  11. extern id infoManager;
  12. extern id processManager;
  13.  
  14. /*===========================================================================
  15.  
  16.     File: IconView.m
  17.  
  18.     Purpose:  Each icon is the instantiation of a window object. The
  19.         docView of that window in an instantiation of this object.
  20.  
  21.         When an instance of this object gets a double click, it 
  22.         queries the InfoMgr object for an action.  It then dispatches
  23.         that action either to ProcessManager or myTalk.
  24.  
  25. ===========================================================================*/
  26.  
  27. @implementation IconView
  28.  
  29. -init
  30. {
  31.     [self setFlipped: YES];        /* flip so that TEXT comes out OK */
  32.     myTalk = [[Talk alloc] init];
  33.     [[self window] addToEventMask:NX_MOUSEDOWNMASK];
  34.     return(self);
  35. }
  36.  
  37. -free
  38. {
  39.     [myTalk free];        /* Source of an earlier memory leak. Fixed now! */
  40.     [super free];
  41.     return nil;
  42. }
  43.  
  44. - drawSelf:(const NXRect *)rects :(int)rectCount
  45. {
  46. NXRect   drawRect;
  47. NXPoint  origin;
  48.  
  49.     /* initialize a drawing rectangle */
  50.     drawRect.origin.x = drawRect.origin.y = 0.0;
  51.     drawRect.size.width = drawRect.size.height = 64.0;    /* Icon Size 64x64 */
  52.     origin.x = origin.y = 8.0;
  53.  
  54.     /* draw our bezel */
  55.     NXDrawButton(&drawRect, 0);
  56.     NXInsetRect(&drawRect, 1.0, 1.0);
  57.     NXDrawButton(&drawRect, 0);
  58.     NXInsetRect(&drawRect, -1.0, -1.0);
  59.  
  60.     PSsetgray(1.0);        /* Display user name and tty in white */
  61.     PSmoveto(9.0,17.0);
  62.     PSshow(username);
  63.     PSmoveto(9.0,32.0);
  64.     PSshow(ttyname);
  65.     PSmoveto(9.0,47.0);
  66.     PSshow(hostname);
  67.     PSstroke();
  68.  
  69.     PSsetgray(0.0);        /* Display user name and tty in black */
  70.     PSmoveto(9.0,18.0);
  71.     PSshow(username);
  72.     PSmoveto(8.0,33.0);
  73.     PSshow(ttyname);
  74.     PSmoveto(8.0,48.0);
  75.     PSshow(hostname);
  76.     PSstroke();
  77.  
  78.     return self;
  79. }    
  80.  
  81. #define MOVEMASK (NX_MOUSEUPMASK|NX_MOUSEDRAGGEDMASK)
  82. - mouseDown:(NXEvent *)theEvent
  83. {
  84.     if (theEvent->data.mouse.click == 2)
  85.     {
  86.         switch([infoManager doubleClickEvent])
  87.         {
  88.             case INFO_TALK:
  89.                 if ([infoManager confirmDoubleClick:"Initiate talk connection?"])
  90.                     [myTalk talk:username tty:ttyname host:hostname];
  91.                 break;
  92.  
  93.             case INFO_TTY_PROCESS:
  94.                 if ([infoManager confirmDoubleClick:"TTY process listing?"])
  95.                     [processManager readTTYProcesses:ttyname];
  96.                 break;
  97.  
  98.             case INFO_USER_PROCESS:
  99.                 if ([infoManager confirmDoubleClick:"User process listing?"])
  100.                     [processManager readUserProcesses:username];
  101.                 break;
  102.  
  103.             case INFO_LOGOUT:
  104.                 if ([infoManager confirmDoubleClick:"Logout?"])
  105.                     [processManager logoutTTY:ttyname];
  106.                 break;
  107.         }
  108.  
  109.     }
  110.     return self;
  111. }
  112.  
  113. /*===========================================================================
  114.  
  115.     The following methods set various instance variables for this 
  116.     object.
  117.  
  118. ===========================================================================*/
  119.  
  120. - iconSetTty: (const char *) tty
  121. {
  122.     strcpy(ttyname, tty);    /* Set tty name */
  123.     return(self);
  124. }
  125.  
  126. - iconSetName: (const char *) name
  127. {
  128.     strcpy(username, name);    /* Set user name */
  129.     username[8] = '\000';
  130.     return(self);
  131. }
  132.  
  133. - iconSetHostName: (const char *) name
  134. {
  135.     strcpy(hostname, name);    /* Set user name */
  136.     return(self);
  137. }
  138.  
  139. @end
  140.  
  141.  
  142.  
  143.